package com.linian.pushforcampus.mapper;

import com.linian.pushforcampus.domain.WechatAccessToken;
import org.apache.ibatis.annotations.*;

/**
 * packageName com.linian.pushforcampus.mapper
 *
 * @author Lennon
 * @className WeChatAccessToken
 * @date 2023/11/12
 * @description TODO
 */

@Mapper
public interface WeChatAccessTokenMapper {
    @Select("SELECT * FROM token")
    WechatAccessToken getAllWechatAccessToken();

    @Select("SELECT * FROM token WHERE id = #{id}")
    WechatAccessToken getWechatAccessTokenById(@Param("id") Integer id);

    @Insert("INSERT INTO token (access_token) " + "VALUES (#{wechatAccessToken.accessToken})")
    @Options(useGeneratedKeys = true, keyProperty = "wechatAccessToken.id")
    void insertWechatAccessToken(@Param("wechatAccessToken") WechatAccessToken wechatAccessToken);

    @Update("UPDATE token SET access_token = #{wechatAccessToken.accessToken} WHERE id = #{wechatAccessToken.id}")
    void updateWechatAccessToken(@Param("wechatAccessToken") WechatAccessToken wechatAccessToken);

    @Delete("DELETE FROM token WHERE id = #{id}")
    void deleteWechatAccessTokenById(@Param("id") Integer id);

}
